import { createRouter, createWebHashHistory } from "vue-router";
import Index from "@/pages/index.vue"
import NotFound from '@/pages/404.vue'
import Login from "@/pages/login.vue"
import Admin from '@/layouts/admin.vue'
import GoodsList from "@/pages/goods/list.vue"


// 统一在这里声明所有路由
const routes = [
    {
        path: "/",
        component: Admin,
        // 后台子路由
        children: [{

            path: "/",
            component: Index,
            meta: {
                title: "后台首页"
            }
        },
        {

            path: "/goods/list",
            component: GoodsList,
            meta: {
                title: "商品列表"
            }
        }
        ]

    },
    {
        path: "/:pathMatch(.*)*",
        component: NotFound,
        meta: {
            title: "404页面"
        }
    },
    {
        path: "/login",
        component: Login,
        meta: {
            title: "登录页面"
        }
    },
    {
        path: "/login",
        component: Login,
        meta: {
            title: "登录页面"
        }
    }
]

// 创建路由
const router = createRouter({
    // 指定路由的历史管理方式，hash 模式指的是 URL 的路径是通过 hash 符号（#）进行标识
    history: createWebHashHistory(),
    // routes: routes 的缩写
    routes,
})

// ES6 模块导出语句，它用于将 router 对象导出，以便其他文件可以导入和使用这个对象
export default router